package com.niit.controller;

import com.niit.entity.Student;
import com.niit.mapper.StudentMapper;
import com.niit.util.MybatisUtil;
import org.apache.ibatis.session.SqlSession;

public class TestSelect {
    public static void main(String[] args) {

        // 使用工具类，创建SqlSession对象
        SqlSession sqlSession = MybatisUtil.getSqlSession();

        // 获取Mapper接口对象  "代理类"
        // 1) class A implements StudentMapper  2) new class A()
        // StudentMapper mapper = new A();
        StudentMapper mapper = sqlSession.getMapper(StudentMapper.class);

        Student student = mapper.getStudentBySid("2022204440 or 1=1");

        System.out.println(student.getSname());
        //-------------------------第二个查询---------------------------

        Student student2= mapper.getStudentByNameAndBatch("刘宇", "22软件外包01班");
        System.out.println(student2.getSid());
    }
}
